DROP FUNCTION IF EXISTS usp_[%tablename%]_sel_by_[%fks%]([%datatypesize%]);
CREATE OR REPLACE FUNCTION usp_[%tablename%]_sel_by_[%fks%] (
  [%params%]
)  RETURNS TABLE ([%columnstypes%]) AS
-- Select a set of [%tablename%] table records by [%fks%].
--  [%datestamp%] - auto generated
BEGIN 
	RETURN QUERY
  SELECT
    [%columns%] 
  FROM [%tablename%] t
  WHERE 
    -- t.[%fieldname%] = @[%fieldname%]  
    [%fieldnames%]  AND
    t.is_deleted = 0;
END;
$$ LANGUAGE plpgsql;